extends KinematicBody2D


export var speed=5
#每次繁殖的小蟑螂的增量
export var to_add_make_child=50
var collide_obj
var collide_name
#到食物节点的距离
var distance_toFood
var ScreenRoot
#食物节点
var foodNode
var PlayerUi=load("res://Scenes/PlayerUi.tscn").instance()
func _ready():
#	ScreenRoot=get_tree().current_scene.get_node(".")
#	print(ScreenRoot)
#	#if ScreenRoot:
#		#print(ScreenRoot.has_Food)
#	if ScreenRoot.has_Food:
#		foodNode=ScreenRoot.find_node("food")
#		print(foodNode)
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
# warning-ignore:unused_argument
func _process(delta):
	if Input.is_action_pressed("ui_up"):
		collide_obj=move_and_collide(Vector2(0,-speed))
	if Input.is_action_pressed("ui_down"):	
		collide_obj=move_and_collide(Vector2(0,speed))
	if Input.is_action_pressed("ui_left"):
		collide_obj=move_and_collide(Vector2(-speed,0))
	if Input.is_action_pressed("ui_right"):
		collide_obj=move_and_collide(Vector2(speed,0))
	if collide_obj:
		collide_name=collide_obj.get_collider().name
		#print(collide_name)
		Global.now_col_obj_name=collide_name
		Global.now_col_obj=collide_obj.collider
	pass
